from typing import Annotated

from fastapi import BackgroundTasks, Depends, Request

from src.core.pipeline import PipelineManager
from src.web.v1.services import PipelineManagerDep
from src.web.v1.services.question_recommendation import QuestionRecommendation as QuestionRecommendationService

def get_pipeline_manager_with_request_id(
    request: Request, background_tasks: BackgroundTasks, pipeline_manager: PipelineManagerDep
) -> PipelineManager:
    """Get a pipeline manager with a request ID."""
    pipeline_manager.set_background_tasks(background_tasks)
    pipeline_manager.set_id(request.state.request_id)
    return pipeline_manager

# 创建一个新的依赖类型
PipelineManagerWithRequestIdDep = Annotated[PipelineManager, Depends(get_pipeline_manager_with_request_id)]

def get_service(service_container=Depends(get_service_container)) -> QuestionRecommendationService:
    """Get the question recommendation service."""
    return service_container.question_recommendation 